import random
while True:
    print('*' * 30, '猜字游戏：猜一个1到100的整数', '*' * 30)
    target = random.randint(1,100)
    i = 1
    while i <= 6:
        guess = int(input("请输入你的猜测："))
        if guess == target:
            print("猜对啦，正确数字是：%s"%guess)
            break
        else:
            if guess > target:
                print("猜大啦")
            else:
                print("猜小了")
            change = 6- i
            print("再猜，还有%s次机会"%change)
        i += 1
    print("游戏结束，正确答案是：%s"%target)
